package com.demo.controller;

import com.demo.dto.StageDto;
import com.demo.service.StageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * @ClassName StageController
 * @Description TODO
 * @Author Windy
 * @Date 2022/9/4 10:31
 * @Version 1.0
 **/
@Controller
@RequestMapping("stage")
public class StageController {
    @Autowired
    StageService stageService;

    @GetMapping("getStage/{id}")
    public String getStage(@PathVariable("id") String id){
        StageDto stageById = stageService.findStageById(id);
        System.out.println(stageById);
        return "success";
    }

    @GetMapping("getStage/{name}")
    public String getStageByName(@PathVariable("name") String name){
        StageDto stage = stageService.findStageByName(name);
        System.out.println(stage);
        return "success";
    }

    @GetMapping("getStage")
    public String getStageAll(){
        List<StageDto> all = stageService.findAll();
        all.forEach(o-> System.out.println(o));
        return "success";
    }

}
